// firstPackage/pages/customManager/customerFllowDetail/customerFllowDetail.js
import { queryClientDetail } from "../../../../service/custom_service"

let app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    themeStyle: "",
    steps: [

    ],
    stepActive: 0,
    id: null,
    info: {},


  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      id: options.id
    })
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    if (app.globalData.themeStyle) {
      this.setData({
        themeStyle: app.globalData.themeStyle
      })
    }
    wx.showLoading();
    queryClientDetail(this.data.id).then(res => {
      wx.hideLoading();
      console.log("JJLog:客户详情是:" + JSON.stringify(res));
      if (res.code == 200) {
        this.setData({
          info: res.data
        })
        if (res.data.follows.length > 0) {
          let arr = [];
          res.data.follows.forEach((item) => {
            let obj = {
              text: item.createdAt,
              desc: item.content
            }
            arr.push(obj)

          })
          this.setData({
            steps: arr,
            stepActive: arr.length - 1
          })
        }
      }
    }).catch(err => {
      wx.hideLoading();
      console.log("JJLog:获取详情失败:" + JSON.stringify(err));
    })
  },

  //添加跟进
  addFollowAction() {
    wx.navigateTo({
      url: '/firstPackage/pages/customManager/customFllow/customFllow?id=' + this.data.id,
    })
  },


  pushToDetailAction(e) {
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/firstPackage/pages/reportModule/reportRecordDetail/reportRecordDetail?id=' + id,
    })
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

})